import * as Cesium from 'cesium';
import { CzmVOption, ESJFlyToParam, ESJVector2D, ESJVector2DArray, ESJVector3D, ESJVector4D, ESViewer, ESVOption, GroupProperty, StringProperty } from 'earthsdk2s';
import { extendClassProps, ObjResettingWithEvent, react, UniteChanged } from 'xbsj-base';
import { ViewerCreating } from './ViewerCreating';
export class ESCesiumViewer extends ESViewer {
    static readonly type = this.register('ESCesiumViewer', this);
    private _viewer = this.dv(react<Cesium.Viewer | undefined>(undefined));
    get viewer() { return this._viewer.value; }

    constructor(option: ESVOption) {
        super(option);
        if (option.type !== 'ESCesiumViewer') throw new Error('option.type must be ESCesiumViewer');
        const opt = option as CzmVOption;
        this.d(this._viewer.changed.don(() => { this.viewerChanged.emit(this.viewer); }));
        this.dv(new ObjResettingWithEvent(this.subContainerChanged, () => {
            this.setStaus('Raw');
            this.setStatusLog('');
            if (!this.subContainer) return undefined;
            return new ViewerCreating(this.subContainer, this, (viewer) => (this._viewer.value = viewer), opt.options);
        }));

    }

    //todo : 抽象函数实现
    pick(screenPosition: ESJVector2D, attachedInfo?: any, parentInfo?: boolean) {
        return '' as any;
    }
    pickPosition(screenPosition: ESJVector2D) {
        return '' as any;
    }
    flyIn(position: ESJVector3D, rotation?: ESJVector3D, duration?: number) {
        return '' as any;
    }
    flyTo(flyToParam: ESJFlyToParam, position: ESJVector3D) {
        return '' as any;
    }
    flyToBoundingSphere(rectangle: ESJVector4D, distance?: number, duration?: number | undefined) {
        return '' as any;
    }
    getCurrentCameraInfo() {
        return '' as any;
    }
    getLengthInPixel() {
        return '' as any;
    }
    changeToWalk(position: ESJVector3D) {
        return '' as any;
    }
    changeToMap() {
        return '' as any;
    }
    changeToRotateGlobe(latitude?: number, height?: number, cycleTime?: number) {
        return '' as any;
    }
    changeToLine(geoLineStringId: string, speed?: number, heightOffset?: number, loop?: boolean, turnRateDPS?: number, lineMode?: "auto" | "manual") {
        return '' as any;
    }
    changeToUserDefined(userDefinedPawn: string) {
        return '' as any;
    };
    changeToRotatePoint(position: ESJVector3D, distance?: number, orbitPeriod?: number, heading?: number, pitch?: number) {
        return '' as any;
    }
    changeToFollow(objectId: string, distance?: number, heading?: number, pitch?: number) {
        return '' as any;
    }
    getFPS() {
        return '' as any;
    }
    getVersion() {
        return '' as any;
    }
    getHeightByLonLat(lon: number, lat: number, channel?: string) {
        return '' as any;
    }
    getHeightsByLonLats(lonLats: ESJVector2DArray, channel?: string) {
        return '' as any;
    }
    capture(resx?: number, resy?: number) {
        return '' as any;
    }
    lonLatAltToScreenPosition(position: ESJVector3D) {
        return '' as any;
    }



    override getProperties() {
        return [
            ...super.getProperties(),
            new GroupProperty('ESCesiumViewer', 'ESCesiumViewer', [
                new StringProperty('ionAccessToken', 'ionAccessToken', false, false, [this, 'ionAccessToken']),
            ])
        ];
    }



}
export namespace ESCesiumViewer {
    export const createDefaultProps = () => ({
        ...ESViewer.createDefaultProps(),
        //todo 需要补全其他属性
    });
}
extendClassProps(ESCesiumViewer.prototype, ESCesiumViewer.createDefaultProps);
export interface ESCesiumViewer extends UniteChanged<ReturnType<typeof ESCesiumViewer.createDefaultProps>> { }

